﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DiedBGController : MonoBehaviour
{
    public Transform player;
    float BG_A;

    void Start()
    {
        BG_A = GetComponent<SpriteRenderer>().color.a;
    }
    void Update()
    {
        if (player!= null)
        {
            if (player.GetComponent<PlayerController>().hp <= 0)
            {
                GetComponent<SpriteRenderer>().color = new Color(0, 0, 0, BG_A += Time.deltaTime);
            }
        }

        //if (player == null)
        //{
        //    GetComponent<SpriteRenderer>().color = new Color(0, 0, 0, BG_A += 0.01F);
        //}
        //else
        //{
        //    GetComponent<SpriteRenderer>().color = new Color(0, 0, 0, 0);
        //}
    }
}
